import 'dart:ui';

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/painting.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData(
        useMaterial3: false,
        primarySwatch: Colors.yellow,
      ),
      home: Scaffold(
        appBar: AppBar(title: const Text("Flutter App")),
        body: const MyHomePage(),
      ),
    );
  }
}

class MyHomePage extends StatelessWidget {
  const MyHomePage({super.key});

  @override
  Widget build(BuildContext context) {
    //获取当前设备尺寸
   final size = MediaQuery.of(context).size;

    return Stack(
      children: [
        ListView(
          padding: const EdgeInsets.only(top: 44),
          children: const [
            ListTile(title: Text("我是一件商品1"),),
            ListTile(title: Text("我是一件商品2"),),
            ListTile(title: Text("我是一件商品3"),),
            ListTile(title: Text("我是一件商品4"),),
            ListTile(title: Text("我是一件商品5"),),
            ListTile(title: Text("我是一件商品6"),),
            ListTile(title: Text("我是一件商品7"),),
            ListTile(title: Text("我是一件商品8"),),
            ListTile(title: Text("我是一件商品9"),),
            ListTile(title: Text("我是一件商品10"),),
            ListTile(title: Text("我是一件商品11"),),
            ListTile(title: Text("我是一件商品12"),),
            ListTile(title: Text("我是一件商品13"),),
            ListTile(title: Text("我是一件商品14"),),
            ListTile(title: Text("我是一件商品15"),),
          ],
        ),
        Positioned(
          left: 0,
          top: 0,
          //在Positioned内指定子元素的高度与宽度
          width: size.width,
          height: 44,
          child: Container(
            alignment: Alignment.center,
            color: Colors.black,
            child: const Text("二级导航",style: TextStyle(color: Colors.white),),
          )
        ),
      ],
    );
  }
}
